
<?php include_once 'common/header.php';  ?>
<!-- admin_main -->
<div class="admin_main">
	<!-- Admin_top end -->
	<?php include_once 'common/system_left.php';  ?>
	<!-- Admin_Left End -->
	<div class="admin_right">
	<div class="admin_right_title"><strong>系统参数</strong> >> 参数列表</div>

		<div class="admin_right_con" style="width: 98%">
			
			<table border="0" cellspacing="1" cellpadding="0" bgcolor="#cfe6f4" width="100%">
			  <tr style="color:#0068b7;">
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>ID</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>参数名称</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>参数标识</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>参数值</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>操作</strong></td>
			  </tr>
			  <?php foreach($sys_list as $info){?>
			  <tr>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['id'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['name'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['nid'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['fvalue'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><a  href="javascript:editsystem(<?php echo $info['id'];?>);" >修改 | <a href="javascript:if(confirm('确定删除？')){remove(<?php echo $info['id'];?>);}">删除</a></a> </td>
			  </tr>
			  <?php }?>
			  <tr>
			  	<td  height="35" colspan="10" align="center" class="page" bgcolor="#FFFFFF"><?php echo $this->pagination->create_links();?></td>
			  </tr>
			</table>
			
			</div>
	</div>
<!-- Admin_Right End -->
</div>
<!-- admin_main end -->

<div id="dialog" title="系统提示" style="display:none;">
<div id="msg" style="text-align:center;color:red">&nbsp;</div>
<input type="hidden" name="id" id="id" />

<p id="sysftype"></p> <br />
<p id="sysname"></p> <br />
<p id="sysnid"></p> <br />
值：<input type="text" name="fvalue" id="fvalue" size="50" /> <br /><br />

<div style="text-align:center;">
<input type="button" style="width: 60px; height:24px" value="关闭" onclick="$('#dialog').dialog('close');"/>
<input type="button" style="width: 60px; height:24px" value="修改" onclick="submitsystem();" />
</div>
</div>

<script>

function editsystem(id){
	if(id>0){
		$( "#dialog" ).dialog({
			height:250,
			width:500,
			modal:true, //蒙层（弹出会影响页面大小）
			title:'编辑参数值'
		});
		
		$( "#id").val(id);
		
		$.ajax({
			type: "POST",
			url: "/ychadmin/systemset/sys_synchronize",
			data: "id="+$("#id").val(),
			success: function(ret){
				$("#sysftype").html('参数类型：'+ret.msg.ftype);
				$("#sysname").html('参数名称：'+ret.msg.name);
				$("#sysnid").html('参数标识：'+ret.msg.nid);
				$("#fvalue").val(ret.msg.fvalue);
			},
			dataType: "json"
		});
	}
}

function submitsystem(){
	var id = $("#id").val();
	if(id > 0){
		$.ajax({
			type: "POST",
			url: "/ychadmin/systemset/addparameter",
			data: "act=edit&id="+id+"&fvalue="+$("#fvalue").val(),
			success: function(ret){
				$("#dialog" ).dialog();
				$("#msg").html(ret.msg);
				setTimeout(function(){
					$("#dialog" ).dialog("close");
				},5000);
				window.location.reload();
			},
			dataType: "json"
		});	
	}
}

function remove(id){
	if(confirm('你确定要删除?'))
	{
		if(id > 0){
			$.ajax({
				type: "POST",
				url: "/ychadmin/systemset/addparameter",
				data: "act=delete&id="+id,
				success: function(ret){
					window.location.reload();
				},
				dataType: "json"
			});	
		}	
	}
}
</script>

</body>
</html>
